﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using PlanningGIS.Framework;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
////using ESRI.ArcGIS.TOCControl;
using PlanningGIS.TocContextMenu.Form;
using PlanningGIS.Symbol;

namespace PlanningGIS.TocContextMenu.Button
{
    /// <summary>
    /// 作用：栅格符号化设置
    /// 作者：
    /// 编写日期：2009-03-25
    /// </summary>
    internal class RasterLayerSymbology : BaseCommand 
    {
        IApplication m_Application = null;
        public RasterLayerSymbology()
        {
            base.m_caption = "栅格符号化设置";
            base.m_toolTip = base.Caption;
        }
       
        public override void OnCreate(object hook)
        {
            m_Application = hook as IApplication;
        }

        public override void OnClick()
        {
            IRasterLayer pRsLyr = (m_Application as IFramework).TOCControl.CustomProperty as IRasterLayer;
            FrmRasterRender myform = new FrmRasterRender();
            myform.RasterLayer = pRsLyr;
            myform.ApplyChangedEvent += delegate(object sender2, EventArgs e2)
            {
                (m_Application as IFramework).MapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                (m_Application as IFramework).TOCControl.Update();
            };
            myform.ShowDialog();
        }
        public override bool Enabled
        {
            get
            {
                return ((m_Application as IFramework).TOCControl.CustomProperty is IGdbRasterCatalogLayer || (m_Application as IFramework).TOCControl.CustomProperty is IRasterLayer) ? true : false;
            }
        }
        public override int Bitmap
        {
            get
            {
                string bitmapResourceName = "PlanningGIS.TocContextMenu.Res." + this.GetType().Name + ".ico";
                System.IO.Stream stream = GetType().Assembly.GetManifestResourceStream(bitmapResourceName);
                if (stream == null) return 0;

                return new Bitmap(stream).GetHbitmap().ToInt32();
            }
        }

    }
    
}
